package com.accp.vehiclecare.action.syhaction;

import com.accp.vehiclecare.biz.syhbiz.SubjoinitemBiz;
import com.accp.vehiclecare.pojo.Subjoinitem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("api/sub")
public class SubjoinitemAction {

    @Autowired
    private SubjoinitemBiz biz;

    @PostMapping("addSub")
    private Map<String,Object> addSub(@RequestBody Subjoinitem subjoinitem){
        Map<String,Object> m = new HashMap<>();
        if (biz.addSubjoinitem(subjoinitem)){
            m.put("code",200);
            m.put("msg","ok");
        }else {
            m.put("code",301);
            m.put("msg","no");
        }
        return m;
    }

    @GetMapping
    private List<Subjoinitem> querysub(String billNo){
        return biz.querySub(billNo);
    }

    @DeleteMapping("removeSub")
    private Map<String,Object> remove(Integer id){
        Map<String,Object> m = new HashMap<>();
        biz.removeSub(id);
        m.put("code",200);
        m.put("msg","ok");
        return m;
    }
}
